home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / misc / samples2 / newform.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-07-23  |  2.7 KB  |  89 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    Caption         =   "Form 1"
  4.    ClientHeight    =   5820
  5.    ClientLeft      =   1095
  6.    ClientTop       =   1755
  7.    ClientWidth     =   7365
  8.    Height          =   6510
  9.    Left            =   1035
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   5820
  12.    ScaleWidth      =   7365
  13.    Top             =   1125
  14.    Width           =   7485
  15.    Begin CommandButton Command2 
  16.       Caption         =   "Unload Last Form"
  17.       Height          =   465
  18.       Left            =   4200
  19.       TabIndex        =   2
  20.       Top             =   5220
  21.       Width           =   2190
  22.    End
  23.    Begin CommandButton Command1 
  24.       Caption         =   "Create New Form"
  25.       Height          =   480
  26.       Left            =   900
  27.       TabIndex        =   1
  28.       Top             =   5205
  29.       Width           =   1815
  30.    End
  31.    Begin TextBox Text1 
  32.       Height          =   4725
  33.       Left            =   120
  34.       TabIndex        =   0
  35.       Text            =   "This is form 1"
  36.       Top             =   165
  37.       Width           =   7215
  38.    End
  39.    Begin Menu mnuExit 
  40.       Caption         =   "Exit"
  41.    End
  42. Sub Command1_Click ()
  43.     'Increment # of forms created
  44.     iNumForms = iNumForms + 1
  45.     're-dimension the array
  46.     ReDim Preserve MyForm(iNumForms) As Form1
  47.     'Refer to new instance of Form1
  48.     Set MyForm(iNumForms) = New Form1
  49.     'Set the new form's caption
  50.     MyForm(iNumForms).Caption = "Form" + Str$(iNumForms + 1)
  51.     'Change the new form's text box
  52.     MyForm(iNumForms).Text1 = "This is the text box on Form " + Str$(iNumForms + 1)
  53.     'Make the menu bar invisible
  54.     MyForm(iNumForms).mnuExit.Visible = False
  55.     'Set the new form's top and left properties based on
  56.     'those of the previous form
  57.     If iNumForms > 1 Then
  58.     MyForm(iNumForms).Top = MyForm(iNumForms - 1).Top + 300
  59.     MyForm(iNumForms).Left = MyForm(iNumForms - 1).Left + 200
  60.     Else
  61.     MyForm(iNumForms).Top = Form1.Top + 300
  62.     MyForm(iNumForms).Left = Form1.Left + 200
  63.     End If
  64.     'Make the new form visible
  65.     MyForm(iNumForms).Show
  66. End Sub
  67. Sub Command2_Click ()
  68.     'Make sure the design time form is not being unloaded
  69.     If iNumForms = 0 Then
  70.     MsgBox "Can't Unload Design-Time Form"
  71.     Exit Sub
  72.     End If
  73.     'Make the form invisible
  74.     MyForm(iNumForms).Visible = False
  75.     'Free up the form's resources
  76.     Set MyForm(iNumForms) = Nothing
  77.     'Set the new # of forms
  78.     iNumForms = iNumForms - 1
  79. End Sub
  80. Sub Form_Load ()
  81.     Text1 = "This is the text box on Form 1."
  82. End Sub
  83. Sub Form_Unload (Cancel As Integer)
  84.     End
  85. End Sub
  86. Sub mnuExit_Click ()
  87.     Unload Me
  88. End Sub
  89.